package com.example.yunJie.digitalSentry.mapper.one;



import com.example.yunJie.digitalSentry.entity.ClockEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.io.Serializable;
import java.util.List;

public interface ClockMapper {
//    @Insert("<script> insert into sz_clock(clockingTime,personalName,marketId,postId,personalCardNumber,shiftId)\n" +
//            "        values(#{clockingTime},#{personalName},#{marketId},#{postId},#{personalCardNumber},#{shiftId})</script>")
    int insert(ClockEntity clockEntity);

//    @Update("<script>update sz_clock\n" +
//            "        <trim prefix=\"SET\" suffixOverrides=\",\">\n" +
//            "            <if test=\"clockingTime != null\">clockingTime = #{clockingTime},</if>\n" +
//            "            <if test=\"personalName != null\">personalName = #{personalName},</if>\n" +
//            "            <if test=\"marketId != null\">marketId = #{marketId},</if>\n" +
//            "            <if test=\"postId != null\"> postId = #{postId},</if>\n" +
//            "            <if test=\"personalCardNumber != null\">personalCardNumber = #{personalCardNumber},</if>\n" +
//            "            <if test=\"shiftId != null\">shiftId = #{shiftId},</if>\n" +
//            "\n" +
//            "        </trim>\n" +
//            "        where id = #{id}</script>")
    int update(ClockEntity clockEntity);

//    @Delete("<script> delete from sz_clock where id = #{Id}</script>")
    int deleteById(Serializable id);

//    @Delete("<script>delete from sz_clock where id in\n" +
//            "        <foreach collection=\"list\" item=\"id\" open=\"(\" separator=\",\" close=\")\">\n" +
//            "            #{id}\n" +
//            "        </foreach></script>")
    int deleteIdList(List<Integer> idList);

//    @Select("<script>    select  clockingTime,personalName,marketId,postId,personalCardNumber,shiftId\n" +
//            "        from sz_clock\n" +
//            "        where id = #{id}</script>")
    ClockEntity findId(Serializable id);

//    @Select("<script>SELECT\n" +
//            "        *\n" +
//            "        FROM\n" +
//            "            sz_clock\n" +
//            "                LEFT JOIN sz_shift ON sz_shift.id = sz_clock.shiftId\n" +
//            "                LEFT JOIN sz_market ON sz_market.id = sz_clock.marketId\n" +
//            "                LEFT JOIN sz_post ON sz_post.id = sz_clock.postId\n" +
//            "                LEFT JOIN sz_personal ON sz_personal.personalName = sz_clock.personalName\n" +
//            "        <where>\n" +
//            "            <if test=\"marketName != null and marketName != ''\">AND sz_clock.marketId = ( SELECT sz_market.id FROM sz_market WHERE sz_market.marketName = #{marketName} )</if>\n" +
//            "            <if test=\"personalName != null and personalName != ''\"> AND sz_clock.personalName = #{personalName}</if>\n" +
//            "            <if test=\"postName != null and postName != ''\"> and sz_clock.postId = (SELECT sz_post.id FROM sz_post where sz_post.postName = #{postName})</if>\n" +
//            "            <if test=\"startTime != null\">and sz_clock.clockingTime <![CDATA[>=]]> #{startTime} </if>\n" +
//            "            <if test=\"endTime != null\">and sz_clock.clockingTime <![CDATA[<=]]> #{endTime} </if>\n" +
//            "            <if test=\"shiftName != null and shiftName != ''\">and sz_clock.shiftId = (SELECT sz_shift.id FROM sz_shift where sz_shift.shiftName = #{shiftName})</if>\n" +
//            "        </where>\n" +
//            "        order by sz_clock.clockingTime asc</script>")
    List<ClockEntity> findAll(ClockEntity clockEntity);
//    @Select("<script>select * from sz_clock\n" +
//            "        LEFT JOIN sz_shift ON sz_shift.id = sz_clock.shiftId\n" +
//            "        LEFT JOIN sz_market ON sz_market.id = sz_clock.marketId\n" +
//            "        LEFT JOIN sz_post ON sz_post.id = sz_clock.postId\n" +
//            "        LEFT JOIN sz_personal ON sz_personal.personalName = sz_clock.personalName\n" +
//            "        <where>\n" +
//            "            <if test=\"personalName != null and personalName != ''\">and personalName = #{personalName}</if>\n" +
//            "            <if test=\"clockingTime != null\">and clockingTime = #{clockingTime}</if>\n" +
//            "        </where></script>")
    ClockEntity findAllByPersonalNameAndClockingTime(ClockEntity clockEntity);
//    @Select("<script> select * from sz_clock\n" +
//            "        LEFT JOIN sz_shift ON sz_shift.id = sz_clock.shiftId\n" +
//            "        LEFT JOIN sz_market ON sz_market.id = sz_clock.marketId\n" +
//            "        LEFT JOIN sz_post ON sz_post.id = sz_clock.postId\n" +
//            "        LEFT JOIN sz_personal ON sz_personal.personalName = sz_clock.personalName\n" +
//            "        <where>\n" +
//            "            <if test=\"personalName != null and personalName != ''\">and sz_clock.personalName = #{personalName}</if>\n" +
//            "            <if test=\"date != null\">and sz_clock.clockingTime like concat('%',#{date},'%') </if>\n" +
//            "        </where>\n" +
//            "        order by clockingTime asc</script>")
    List<ClockEntity> findByPersonalNameAndDate(String personalName,String date);
}
